package com.zhourong.mongodb.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.zhourong.mongodb.model.User;
import com.zhourong.mongodb.service.IUserService;

@Controller
@RequestMapping("/mongodb/")
public class DemoMongodb {

	@Autowired
	private IUserService userService;


	@RequestMapping("/findUser")
	@ResponseBody
	public User findUserById(Long id) {
		User user = userService.findUserById(id);
		return user;
	}

	@RequestMapping("/insert")
	public void insert(User user) {
		userService.insert(user);

	}

	@RequestMapping("/delete")
	public void delete(User user) {
		userService.delete(user);
	}

	@RequestMapping("/update")
	public void update(User user) {
		userService.update(user);
	}
}
